package com.hyg.hometown.service.imp;

import com.hyg.hometown.dao.RedisParentDao;
import com.hyg.hometown.dao.UserRedis;
import com.hyg.hometown.model.Role;
import com.hyg.hometown.model.User;
import com.hyg.hometown.service.UserService;
import com.hyg.hometown.dao.UserInfoRepository;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 接口实现类
 */
@Service
public class UserServiceImp implements UserService {
    @Resource
    private UserInfoRepository userInfoRepository;

    @Resource
    private UserRedis userRedis;
    @Override
    public User getUserByUserName(String userName) {
        return this.userInfoRepository.getUsersByUsername(userName);
    }

    @Override
    public User addUser(Map<String, Object> map) {
        return null;
    }

    @Override
    public Role addRole(Map<String, Object> map) {
        return null;
    }

    @Override
    public void addRedisUserInfo(String userName,UsernamePasswordToken usernamePasswordToken) {
        userRedis.setUser(usernamePasswordToken.getUsername(),usernamePasswordToken.getUsername());
    }
}
